from sklearn.neighbors import KNeighborsClassifier

# 1.准备数据集
# 训练值
x = [
    [10,10,20,40],
    [30, 10, 20, 4],
    [20, 1, 2, 40],
]
# 目标值
y = [1,2,1]
# 2.定义训练器,k值的选取问题
estimator = KNeighborsClassifier(n_neighbors=2)
# 3.训练
estimator.fit(x,y)
# 4.预测
rs = estimator.predict([[10,10,9,1],[1,1,9,1]])
print(rs)
